import axios from "@/utils/http";

const category = {
  // 获取所有分类
  getAllCategory() {
    return axios.get("/api/category");
  },

  // 获取某个分类下的博客列表
  getBlogListByCategoryId(params) {
    return axios.get("/api/category/getBlogListByCategoryId", { params });
  },

  // 新增分类
  add(params) {
    return axios.post("/api/category", params);
  },

  // 删除分类
  delete(categoryId) {
    return axios.delete(`/api/category/${categoryId}`);
  },

  // 更新分类
  update(params) {
    const categoryId = params.categoryId;
    return axios.put(`/api/category/${categoryId}`, params);
  }
};

export default category;
